unit F_RCopiasPorDocumento;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, F_ABM_Documentos, ZAbstractDataset, ZDataset, DB,
  ZAbstractRODataset, JvComponentBase, JvFormPlacement, Grids, DBGrids,
  JvExDBGrids, JvDBGrid, JvDBUltimGrid, JvExControls, JvDBLookup, StdCtrls,
  JvSpeedButton, ExtCtrls;

type
  TF_CopiasPorDocumento = class(TABM_Documentos)
    JvSpeedButton1: TJvSpeedButton;
    procedure JvSpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


implementation

uses R_CopiasPorDocumento;

{$R *.dfm}

procedure TF_CopiasPorDocumento.JvSpeedButton1Click(Sender: TObject);
var
  i: integer;
  Aux: string;
begin
  inherited;
  if JvDBUltimGrid.SelectedRows.Count > 0 then
  begin
    with JvDBUltimGrid.DataSource.DataSet do
    begin
      for i := 0 to JvDBUltimGrid.SelectedRows.Count-1 do
      begin
        GotoBookmark(Pointer(JvDBUltimGrid.SelectedRows.Items[i]));
        Aux:= Aux+FieldByName('id').AsString+', ';
      end;
    end;
    Aux:= Copy(Aux, 1, Length(Aux)-2);

    with TR_CopiaPorDocumento.Create(Self, Aux) do
    try
      QuickRep1.Preview;
    finally
      QuickRep1.Free;
    end;

  end;
end;

end.
